package com.demo.phone.autohome.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author : YU.TAN
 * @date : 2021/10/27 10:33
 */
@AllArgsConstructor
@Getter
public enum ResultEnum {

    /**
     *
     */

    SUCCESS(0, "正确执行"),
    FAIL(-1, "执行失败原因描述"),
    MISS_PARAMETER(101, "缺少必要的请求参数"),
    ERROR_PARAMETER_FORMAT(102, "请求参数格式错误"),
    ENCRYPTION_EMPTY(1001, "加密字符串为空,加密校验未进行"),
    ENCRYPTION_VERIFY_FAIL(1002, "加密校验未通过"),
    FAIL_DEALER_MAPPING(1003, "获取不到映射经销商"),
    ORDER_EMPTY(1004, "订单信息不存在"),
    MISS_DEALER(1005, "厂商包含的经销商中未找到订单中的经销商"),
    UNKNOWN(-101, "未知"),
    ;

    private final int returncode;
    private final String message;

    public static ResultEnum getByCode(int code) {
        for (ResultEnum resultEnum : ResultEnum.values()) {
            if (code == resultEnum.getReturncode()) {
                return resultEnum;
            }
        }
        return UNKNOWN;
    }
}
